<template>
  <a-card :bordered="false">
    <h2>安全设置</h2>
    <div class="setAccount" style="width:50%;margin:20px auto;">
      <a-form :form="form">
          <!-- <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="当前密码">
            <a-input placeholder="请输入当前密码" type="password" v-model="form.oldPassword" />
          </a-form-item> -->
          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="新密码">
            <a-input placeholder="请输入新密码" type="password"  v-model="form.password" />
          </a-form-item>
          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="确认新密码">
            <a-input placeholder="请输入新密码" type="password"  v-model="form.confirmPassword" />
          </a-form-item>
          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            class="special-action"
            label="操作">
            <a-button type="primary" @click="changePassword">提交</a-button>
          </a-form-item>
      </a-form>
    </div>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import LabelModal from './modules/LabelModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { httpAction,postAction } from '@/api/manage'
  export default {
    name: "account",
    mixins:[JeecgListMixin],
    components: {
      LabelModal
    },
    data () {
      return {
        form:{},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        description: '安全设置',
        
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
      changePassword(){
        if(!this.form.password || !this.form.confirmPassword){
          this.$message.error('请输入完整信息')
          return false;
        }
        if(this.form.password !== this.form.confirmPassword){
          this.$message.error('两次密码输入不一致')
          return false;
        }
        let httpurl = '/sys/user/changePassword';
        let method = 'put';
        
        let formData = Object.assign(this.form, {});
        //时间格式化
        
        console.log(formData)
        formData.username = localStorage.getItem('pro__Login_Userinfo')?JSON.parse(localStorage.getItem('pro__Login_Userinfo')).value.username:'';
        httpAction(httpurl,formData,method).then((res)=>{
          if(res.success){
            this.$message.success(res.message);
            // that.$emit('ok');
          }else{
            this.$message.warning(res.message);
          }
        }).finally(() => {
          // that.confirmLoading = false;
          // that.close();
        })
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';

</style>